<template>
  <div class="cates">
    <van-tabs @click="tabClick" color="#7744FF" background="#ccc">
      <van-tab v-for="item in cates" :key="item.id" :title="item.catename"
      :name="item.id"
      >
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import {reqHomeCate} from "../../../http/api"
export default {
  data() {
    return {
      cates: [],
    };
  },
  mounted() {
    //1.2 获取分类的数据
    reqHomeCate().then((res) => {
      this.cates = res.data.list; 
    });
  },
  methods:{
    tabClick(e){
      this.$router.push("/list?id="+e+"&type=1")
    }
  }
};
</script>

<style scoped lang="less">
@import "../../../less/index.less";
.cates {
  overflow: hidden;
  a {
    float: left;
    margin: @margin20;
  }
}

a {
  display: inline-block;
  margin: @margin20;
}
</style>